﻿SELECT
	[main].object_id AS [ObjectId],
	[schema].[name] AS [SchemaName],
	[main].[name] AS [ObjectName],
	[main].[parent_id] AS [TableId],
	[main].[type_desc] AS [ImplementationType],
	CASE [parent_class]
		WHEN 1 THEN 'DML'
		ELSE 'DDL'
	END AS [OperationType],
	[main].[is_instead_of_trigger] AS [IsInsteadOfTrigger],
	[evnt].[type_desc] AS [EventName],
	object_definition([main].[object_id]) AS [Definition]
FROM sys.triggers [main]
INNER JOIN sys.trigger_events [evnt] ON [main].object_id = [evnt].object_id
LEFT OUTER JOIN sys.objects [obj] ON [main].object_id = [obj].object_id
LEFT OUTER JOIN sys.schemas [schema] ON [obj].[schema_id] = [schema].[schema_id]
WHERE
	1 = 1 -- Added because the code will not put the "WHERE" statement into the query if it wants to add a where clause
	-- [WHERECLAUSE]
